From: Keir Fraser Date: Tue, 6 Apr 2010 05:59:32 +0000 (+0100) Subject: CSCHED: Optimize __runq_tickle to reduce IPIs X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~12443 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/success//%22http:/www.example.com/cgi/success/?a=commitdiff_plain;h=e4434634c4a66c9285be4e99da24daf50fc76b8f;p=xen.git CSCHED: Optimize __runq_tickle to reduce IPIs Limiting the number of idle cpus tickled for vcpu migration purpose to ONLY ONE to get rid of a lot of IPI events which may impact the average cpu idle residency time. The default on option 'tickle_one_idle_cpu=0' can be used to disable this optimization if needed. Signed-off-by: Wei Gang --- diff --git a/xen/common/sched_credit.c b/xen/common/sched_credit.c index bb85b94315..11d26421e0 100644 --- a/xen/common/sched_credit.c +++ b/xen/common/sched_credit.c @@ -228,6 +228,11 @@ static void burn_credits(struct csched_vcpu *svc, s_time_t now) svc->start_time += (credits * MILLISECS(1)) / CSCHED_CREDITS_PER_MSEC; } +static int opt_tickle_one_idle __read_mostly = 1; +boolean_param("tickle_one_idle_cpu", opt_tickle_one_idle); + +DEFINE_PER_CPU(unsigned int, last_tickle_cpu) = 0; + static inline void __runq_tickle(unsigned int cpu, struct csched_vcpu *new) { @@ -265,8 +270,21 @@ __runq_tickle(unsigned int cpu, struct csched_vcpu *new) } else { - CSCHED_STAT_CRANK(tickle_idlers_some); - cpus_or(mask, mask, csched_priv.idlers); + cpumask_t idle_mask; + + cpus_and(idle_mask, csched_priv.idlers, new->vcpu->cpu_affinity); + if ( !cpus_empty(idle_mask) ) + { + CSCHED_STAT_CRANK(tickle_idlers_some); + if ( opt_tickle_one_idle ) + { + this_cpu(last_tickle_cpu) = + cycle_cpu(this_cpu(last_tickle_cpu), idle_mask); + cpu_set(this_cpu(last_tickle_cpu), mask); + } + else + cpus_or(mask, mask, idle_mask); + } cpus_and(mask, mask, new->vcpu->cpu_affinity); } }